package com.junlaninfo;

import java.lang.ref.WeakReference;
import java.util.HashMap;
import java.util.Map;

/**
 * Created by 辉 on 2020/9/11.
 * 弱引用
 */
public class Test3 {
    public static void main(String[] args) {
        HashMap<String, String> map1 = new HashMap<String, String>();
        WeakReference<Map> map2 = new WeakReference<Map>(map1);
        map1.put("年龄","26");
        map1=null;
        System.out.println(map2.get());
        System.gc();
        System.out.println(map2.get());
    }
}
